package com.example.demo.struct.composite;


/**
 * @Desc:
 * @Author zzz
 * @Date 2021/2/24
 * @Version V1.0
 */
public class CompositeTest {
    public static void main(String[] args) {
        Computer computer = new Computer();

        Host host = new Host();
        Power power = new Power();
        MotherBoard motherBoard = new MotherBoard();
        CPU cpu = new CPU();
        GraphCard graphCard = new GraphCard();
        MemoryCard memoryCard = new MemoryCard();
        SSD ssd = new SSD();
        host.add(power).add(motherBoard).add(cpu).add(ssd).add(graphCard).add(memoryCard);

        Monitor monitor = new Monitor();
        computer.add(host).add(monitor);
        computer.display();
        double sum = computer.calc();
        System.err.println("总计价值" + sum + "元");
    }
}
